agama profile reference updated for the --api URL related changes#70
Merged
agama profile reference updated for the --api URL related changes#70
agama profile reference updated for the --api URL related changes#70Conversation
5 tasks
mvidner
added a commit
to agama-project/agama
that referenced
this pull request
Apr 10, 2025
## Problem `agama profile` still executes its actions directly from the CLI client, not using the web service. Fix it to make it work like `agama --api $URL config ...` already does. - https://trello.com/c/fqPGL2qe `agama profile` command summary... it is a diverse bunch! (related, unplanned stub: https://trello.com/c/3aUupc2F/461-unify-config-and-profile-commands-in-the-cli ) ``` profile_evaluate(jsonnet_path) -> json stdout profile_validate(json_path) -> print whether valid, what problems profile_autoyast(autoyast_url) -> json stdout profile_import(url) -> performs config_load # oh fun! if url ends with .xml OR .erb OR / profile_autoyast else download the file and analyze content if is_script # starts with hash-bang and the program is not "jsonnet" EXECVE it # which means replace current process. OMG WTF inconsistent UX else if is_jsonnet profile_evaluate else if is_json cat else return Error # at this point we have a JSON file profile_validate # NOTE that invalid profile is just a message and we continue agama_config_load ``` ## Solution Added these 3 new web API paths corresponding 1-1 to the CLI commands: - POST /api/profile/validate ?url= ?path= (or body) - POST /api/profile/evaluate ?url= ?path= (or body) - POST /api/profile/autoyast ?url= But `agama profile import` is notable that it effectively includes an `agama config load` which is implemented as multiple backend calls, so `import` stays at the front end and the back end only gets what's needed to make it work, which is running a script: - POST /api/profile/execute_script ?url= ?path= (or body) (TODO explain the rest) ### Backend errors now include their causes Before: > Anyhow(Backend call failed with status 400 and text '{"error":"Error: Could not evaluate the profile"}') After: > Anyhow(Backend call failed with status 400 and text '{"error":"Error: Could not evaluate the profile: Failed to read system's hardware information: Failed to read agama.libsonnet: No such file or directory (os error 2)"}') ### JSON validation errors are more readable now <details> <summary> We used to include a debug representation of the validation error but reading the manual(!) shows there is a way to just point to the offending piece of JSON </summary> ```console $ cat ... { "product": { "ID": "Tumbleweed" }} $ agama profile validate rust/agama-lib/share/examples/profile_tw_invalid.json The profile is not valid. Please, check the following errors: ``` Before: > * Additional properties are not allowed ('ID' was unexpected). ValidationError { instance: Object {"ID": String("Tumbleweed")}, kind: AdditionalProperties { unexpected: ["ID"] }, instance_path: JSONPointer([Property("product")]), schema_path: JSONPointer([Keyword("properties"), Property("product"), Keyword("additionalProperties")]) } > * "id" is a required property. ValidationError { instance: Object {"ID": String("Tumbleweed")}, kind: Required { property: String("id") }, instance_path: JSONPointer([Property("product")]), schema_path: JSONPointer([Keyword("properties"), Property("product"), Keyword("required")]) } After: > * Additional properties are not allowed ('ID' was unexpected). /product > * "id" is a required property. /product </details> ## Testing Unit tests: no ### Manual tests ... ### Added integration tests expecting a running web service. Run like (part of .github/workflows/ci-integration-tests.yml) ```sh (cd service/; bundle exec rspec --pattern 'test/integration/**_itest.rb') ``` - [x] agama profile validate - [x] agama profile evaluate - [x] agama profile autoyast ... turns out hard to test with the AY-special URLs as **none** of them work in my container - [x] agama profile import - [ ] agama --api ... profile ... hitting an opaque SSL handshake error :sob: ## Screenshots (textual screenshots coming up) ## Documentation Documented the extended argument handling: - autoinstallation/README.md adjusted - agama-project/agama-project.github.io#70 But we are actually still missing documentation for the `--api` option itself, except for [a mention in the blog](https://agama-project.github.io/blog/2025/01/21/Agama-11#remotecli). IMHO we should add it as part of the `config`/`profile` cleanup.
imobachgs
approved these changes
Apr 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--api URLsupport toagama profileagama#2103